//
//  MoreMenuView.m
//  MemberProject
//
//  Created by mac on 15/8/7.
//  Copyright (c) 2015年 MAC OS X. All rights reserved.
//

#import "MoreMenuView.h"
#import "MoreMenuViewTableViewCell.h"
@interface MoreMenuView()<UITableViewDelegate,UITableViewDataSource>
@property(strong,nonatomic)NSArray *data;
@property(strong,nonatomic)UITableView *tableView;

@end

@implementation MoreMenuView
-(void)awakeFromNib{
    UIImageView *imageView=(UIImageView *)[self viewWithTag:101];
    imageView.image=[imageView.image stretchableImageWithLeftCapWidth:38 topCapHeight:33];
    
    self.tableView=(UITableView *)[self viewWithTag:100];
    self.tableView.backgroundColor=[UIColor clearColor];
    self.tableView.delegate=self;
    self.tableView.dataSource=self;
    self.tableView.separatorInset=UIEdgeInsetsMake(0, 0, 0, 0);
    self.data=@[@{@"image":[UIImage imageNamed:@"new_refresh"],@"text":@"刷新"},@{@"image":[UIImage imageNamed:@"share_icon"],@"text":@"分享"}];
    
    [self.tableView registerNib:[UINib nibWithNibName:@"MoreMenuViewTableViewCell" bundle:nil] forCellReuseIdentifier:@"CellIdentifier"];
}

- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
    return 44.0f;
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
    return self.data.count;
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    static NSString *CellIdentifier=@"CellIdentifier";
    MoreMenuViewTableViewCell *cell=[tableView dequeueReusableCellWithIdentifier:CellIdentifier forIndexPath:indexPath];
    cell.titleImageView.image=self.data[indexPath.row][@"image"];
    cell.titleLabel.text=self.data[indexPath.row][@"text"];
    return cell;
}

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
    [tableView deselectRowAtIndexPath:indexPath animated:YES];
    if([self.delegate respondsToSelector:@selector(moreMenuView:didSelectRowAtIndexPath:)]){
        [self.delegate moreMenuView:self didSelectRowAtIndexPath:indexPath];
    }
}
@end
